package ckt;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    static Scanner scanner;
    static Database database;


    public static void main(String[] args) {
        database = new Database();
        
        scanner = new Scanner(System.in);
        
        String choose;

        System.out.println("输入1进入cms模块,输入2进入客服端");

        int enter = scanner.nextInt();
        switch (enter) {
            case 1://进入cms模块
                System.out.println("输入1查询车辆信息，输入2插入车辆信息，输入3删除车辆信息,输入4修改");

                int enter_1 = scanner.nextInt();

                switch (enter_1) {

                    case 1://查询并显示车辆信息
                        System.out.println("输入1查询所以车辆信息，输入2查询所有小车信息，输入3查询所有客车信息");

                        int SelectCarData = scanner.nextInt();

                        switch (SelectCarData) {

                            case 1:
                                database.select();
                                break;
                            case 2:
                                //通过选择器类来自动选择
                                MotoVehicle.Obvious(new Mcar());
                                break;
                            case 3:
                                MotoVehicle.Obvious(new Bus());
                                break;

                        }
                        System.out.println("数据查询成功");
                        break;
                    case 2://插入车辆信息
                        intsert();
                        break;
                    case 3://删除车辆
                        System.out.println("输入你要删除车辆信息的车牌号:");
                        choose = scanner.next();
                        database.delete(choose,"Num");
                        break;
                    case 4://修改车辆信息
                        System.out.println("输入车牌号选定要修改信息的车辆：");
                        choose = scanner.next();
                        database.select(choose,"Num");
                        System.out.println("输入要修改的消息的所在列名（车型、车牌、品牌、颜色、座位数、型号、里程、租金");
                        String change = scanner.next();
                        System.out.println("输入要修改信息的内容");
                        String get_content =scanner.next();
                        database.change(get_content,change,choose);


                }
            case 2://进入到客户端模式
                Map<String,Integer> getMap = new HashMap<>();
                database.select();

                while (true){

                    System.out.println("输入心仪的车牌号进行车辆选择：");

                    choose = scanner.next();

                    database.select(choose, "Num");
                    String getType = database.getType();//获得车的类型

                    System.out.println("输入租借天数：");
                    int data_count = scanner.nextInt();

                    getMap.put(getType,data_count);

                    System.out.println("输入1继续选车，输入2结束选车:");

                    int over = scanner.nextInt();
                    if(over ==2){
                        break;

                    }
                }


                new client().CalRent(getMap);

                break;

        }
 }
 //插入车辆信息的方法
    public static void intsert(){
        System.out.println("输入车辆类型（小车、客车）:");

        String gCarType =scanner.next();

        System.out.println("输入车辆车牌（6位字符串):");
        String gNum = scanner.next();

        System.out.println("输入车辆颜色:");
        String gColor= scanner.next();

        System.out.println("输入车辆品牌:");
        String gBrand = scanner.next();

        System.out.println("输入车辆座位数:");
        int gSeaCount = Integer.parseInt(scanner.next());

        System.out.println("输入车辆型号:");
        String gType = scanner.next();

        System.out.println("输入车辆里程(km):");
        int gMeleage =Integer.parseInt(scanner.next());

        System.out.println("输入车辆租金:");
        int gRent =scanner.nextInt();

        if (gCarType.equals("小车")) {
            Mcar mcar = new Mcar(gCarType, gNum, gColor, gBrand, gMeleage, gType,
                    gSeaCount, gRent);
            System.out.println("数据插入成功");
        }else{

            Bus bus= new Bus(gCarType,gNum,gColor,gBrand,gMeleage,gType,
                    gSeaCount,gRent);

            System.out.println("数据查询成功");


        }
    }
}
